/**
 * 
 * 从指定文件中随机获取一条引用
 * 
 */
function getRandomQuote($file_path, &$error = '') {
    $error = '';
    
    if (!file_exists($file_path)) {
        $error = "文件不存在: {$file_path}";
        return false;
    }
    
    if (!is_readable($file_path)) {
        $error = "没有权限读取文件: {$file_path}";
        return false;
    }
    
    $quotes = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    
    if ($quotes === false) {
        $error = "读取文件失败: {$file_path}";
        return false;
    }
    
    if (empty($quotes)) {
        $error = "文件内容为空或只有空行: {$file_path}";
        return false;
    }
    
    return $quotes[array_rand($quotes)];
}

function displayRandomQuote() {
    $quoteFile = dirname(__DIR__, 2) . '/themes/classic-22/biaoti.txt';
    $errorInfo = '';
    $randomQuote = getRandomQuote($quoteFile, $errorInfo);

    if ($randomQuote !== false) {
        echo $randomQuote;
    } else {
        echo "获取引用失败: {$errorInfo}";
    }
}
